#include<iostream>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include "namepipe.hpp"

int main()
{

    key_t key = ftok("/home/fwt/lstudy/SharedMemory", 6686);
    int shmid = shmget(key, 4096, IPC_CREAT);
    char* addr = (char*)shmat(shmid, nullptr, 0);
    perror("shmat:");

    namepipe pipe(pipespace::gpathname, pipespace::gUser);
    pipe.OpenPipeRead();

    std::string buffer ;
    while(pipe.GetMassage(&buffer))
    printf("processB get : %s ", addr);

    shmdt(addr);
    printf("ProcessA quit, I quit too\n");

    return 0;

}